package com.huawei.gamebox.service.welfare.gift.card;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.view.ViewGroup.MarginLayoutParams;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.RecyclerView.n;
import androidx.recyclerview.widget.RecyclerView.s;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.gamebox.service.common.cardkit.card.BaseGsCard;
import com.huawei.gamebox.service.welfare.gift.bean.HorizonScrollGiftListBean;
import o.azb;
import o.cgz;
import o.chy;
import o.ContentManager;
import o.eix;
import o.eiy;
import o.epv;
import o.MinimumFactory;
import o.exp$a;
import o.exp$b;
import o.exp.d;
import o.exp.j;
import o.fcp;

public class HorizonScrollGiftListCard extends BaseGiftCard {
    private LinearLayoutManager ʽ;
    private eix ˊ = new eix();
    private chy ˋ;
    private HorizonScrollGiftListBean ˎ = null;
    private RecyclerView ˏ;
    private a ॱॱ;

    class a extends androidx.recyclerview.widget.RecyclerView.a<a> {
        final /* synthetic */ HorizonScrollGiftListCard ˊ;

        class a extends s {
            final /* synthetic */ a ʻॱ;
            private HorizonGiftCard ॱˋ;
            private View ᐝॱ;

            a(a aVar, View view) {
                this.ʻॱ = aVar;
                super(view);
                this.ॱˋ = new HorizonGiftCard(view.getContext());
                this.ॱˋ.ˊ(view);
                this.ॱˋ.ˉ().setClickable(true);
                this.ᐝॱ = view;
                this.ॱˋ.ॱ(aVar.ˊ.ʻ());
            }
        }

        private a(HorizonScrollGiftListCard horizonScrollGiftListCard) {
            this.ˊ = horizonScrollGiftListCard;
        }

        @NonNull
        public /* synthetic */ s ˎ(@NonNull ViewGroup viewGroup, int i) {
            return ˊ(viewGroup, i);
        }

        public /* synthetic */ void ॱ(@NonNull s sVar, int i) {
            ˎ((a) sVar, i);
        }

        @NonNull
        public a ˊ(@NonNull ViewGroup viewGroup, int i) {
            return new a(this, LayoutInflater.from(viewGroup.getContext()).inflate(j.ˊᐝ, viewGroup, false));
        }

        public void ˎ(@NonNull a aVar, int i) {
            aVar.ॱˋ.ˏ((CardBean) ((HorizonScrollGiftListBean) this.ˊ.ˊᐝ).ˊ().get(i));
            MarginLayoutParams marginLayoutParams = (MarginLayoutParams) aVar.ᐝॱ.getLayoutParams();
            if (marginLayoutParams != null) {
                if (MinimumFactory.getBoolValue(ContentManager.getInstant().getContext())) {
                    ॱ(i, marginLayoutParams);
                } else {
                    ˏ(i, marginLayoutParams);
                }
                aVar.ᐝॱ.setLayoutParams(marginLayoutParams);
            }
        }

        private void ˏ(int i, MarginLayoutParams marginLayoutParams) {
            marginLayoutParams.setMarginEnd(0);
            if (i == 0) {
                marginLayoutParams.setMarginStart(this.ˊ.ˊ.ॱ());
                return;
            }
            if (i == ˏ() - 1) {
                marginLayoutParams.setMarginEnd(this.ˊ.ˊ.ॱ());
            }
            marginLayoutParams.setMarginStart(this.ˊ.ˊ.ॱॱ());
        }

        private void ॱ(int i, MarginLayoutParams marginLayoutParams) {
            marginLayoutParams.setMarginStart(0);
            if (i == 0) {
                marginLayoutParams.setMarginEnd(this.ˊ.ˊ.ॱ());
                return;
            }
            if (i == ˏ() - 1) {
                marginLayoutParams.setMarginStart(this.ˊ.ˊ.ॱ());
            }
            marginLayoutParams.setMarginEnd(this.ˊ.ˊ.ॱॱ());
        }

        public int ˏ() {
            if (this.ˊ.ˎ == null || this.ˊ.ˎ.ˊ() == null) {
                return 0;
            }
            return this.ˊ.ˎ.ˊ().size();
        }
    }

    public /* synthetic */ cgz ˏ(View view) {
        return ˎ(view);
    }

    public HorizonScrollGiftListCard(Context context) {
        super(context);
        this.ˊ.ॱ(context.getResources().getDimensionPixelSize(exp$a.ॱ));
        this.ˊ.ˏ(context.getResources().getDimensionPixelSize(exp$a.ॱ));
        this.ˊ.ˋ(context.getResources().getInteger(exp$b.ˎ));
        this.ˊ.ʼ(context.getResources().getInteger(exp$b.ˏ));
        this.ˊ.ˊ(epv.ˊ());
        this.ˊ.ˎ(azb.ˊ(context));
        this.ˊ.ᐝ(epv.ॱॱ());
    }

    public BaseGsCard ˎ(View view) {
        ʽ(view);
        ॱ((RecyclerView) view.findViewById(d.ˋ));
        this.ॱॱ = new a();
        this.ʽ = new LinearLayoutManager(view.getContext(), 0, false);
        ˊ().setLayoutManager(this.ʽ);
        if (MinimumFactory.getBoolValue(ContentManager.getInstant().getContext())) {
            ˊ().setLayoutDirection(0);
            this.ʽ.ˊ(true);
        }
        ˊ().setAdapter(this.ॱॱ);
        new eiy().ˏ(ˊ());
        this.ˏ.ॱ(new n(this) {
            final /* synthetic */ HorizonScrollGiftListCard ˏ;

            {
                this.ˏ = r1;
            }

            public void ˎ(RecyclerView recyclerView, int i) {
                if (i == 0) {
                    HorizonScrollGiftListBean horizonScrollGiftListBean = (HorizonScrollGiftListBean) this.ˏ.ˌ();
                    Object obj = this.ˏ.ʽ.ॱˎ() == this.ˏ.ʽ.ˌ() + -1 ? 1 : null;
                    int ॱˎ = this.ˏ.ʽ.ॱˎ();
                    this.ˏ.ˊ.ॱॱ(this.ˏ.ʽ.ॱˊ());
                    this.ˏ.ˊ.ʻ(this.ˏ.ˊ().getLeft());
                    if (obj != null) {
                        horizonScrollGiftListBean.ˎ(ॱˎ);
                        horizonScrollGiftListBean.ˏ(this.ˏ.ˊ.ʻ());
                        return;
                    }
                    horizonScrollGiftListBean.ˏ(this.ˏ.ˊ.ʻ());
                    horizonScrollGiftListBean.ˎ(this.ˏ.ˊ.ᐝ());
                }
            }
        });
        return this;
    }

    public void ˏ(CardBean cardBean) {
        super.ˏ(cardBean);
        if (cardBean instanceof HorizonScrollGiftListBean) {
            this.ˎ = (HorizonScrollGiftListBean) cardBean;
            this.ʽ.ॱ(this.ˎ.ᐝ(), this.ˎ.ͺ());
            if (this.ˎ.ʼ() <= 0) {
                this.ˎ.ˊ(new fcp(this.ˊ).ॱ(this.ॱ, this.ˎ.ˊ()));
            }
            LayoutParams layoutParams = this.ˏ.getLayoutParams();
            layoutParams.height = this.ˎ.ʼ();
            this.ˏ.setLayoutParams(layoutParams);
            this.ॱॱ.ˊ();
        }
    }

    public RecyclerView ˊ() {
        return this.ˏ;
    }

    public void ॱ(RecyclerView recyclerView) {
        this.ˏ = recyclerView;
    }

    public chy ʻ() {
        return this.ˋ;
    }

    public void ॱ(chy o_chy) {
        this.ˋ = o_chy;
    }
}
